Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports FaceCat


Public Class MainFrom
    Inherits System.Windows.Forms.Form

    ' Constant value was found in the "windows.h" header file.
    Private Const WM_ACTIVATEAPP As Integer = &H1C
    Private appActive As Boolean = True
    Private m_native As FCNative = Nothing
    Private m_host As WinHost = Nothing
    Private m_xml As FCUIXml = Nothing
    Private m_paint As FCPaint = Nothing
    Private m_xmlStr As String = Application.StartupPath + "\mainframe.xml"
    <STAThread()> _
    Shared Sub Main()
        Application.Run(New MainFrom())
    End Sub 'Main

    Public Sub New()
        MyBase.New()
        InitializeComponent()
        Me.Size = New System.Drawing.Size(800, 600)
        Me.Text = "FaceCat VB.NET"
        Me.Font = New System.Drawing.Font("Segoe UI", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        Me.WindowState = FormWindowState.Maximized
        m_xml = New FaceCat.MainFrame()
        m_xml.createNative()
        m_native = m_xml.getNative()
        m_host = New WinHost()
        m_native.setHost(m_host)
        m_host.setNative(m_native)
        m_paint = New GdiPlusPaint()
        m_native.setPaint(m_paint)
        m_host.setHWnd(Me.Handle)
        m_native.setSize(New FCSize(Me.Width, Me.Height))
        m_xml.loadFile(m_xmlStr, Nothing)
        m_native.update()
        m_native.invalidate()
    End Sub

    <System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
        Protected Overrides Sub WndProc(ByRef m As Message)
        ' Listen for operating system messages
        Select Case (m.Msg)
            ' The WM_ACTIVATEAPP message occurs when the application
            ' becomes the active application or becomes inactive.
            Case WM_ACTIVATEAPP

                ' The WParam value identifies what is occurring.
                appActive = (m.WParam.ToInt32() <> 0)

                ' Invalidate to get new text painted.
                Me.Invalidate()
        End Select
        If IsNothing(m_host) = False Then
            If m_host.onMessage(m) > 0 Then
                Return
            End If
        End If
        MyBase.WndProc(m)
    End Sub

    Private Sub InitializeComponent()
        Me.SuspendLayout()
        '
        'MainFrom
        '
        Me.ClientSize = New System.Drawing.Size(486, 393)
        Me.Name = "MainFrom"
        Me.ResumeLayout(False)

    End Sub
End Class


